<link rel="stylesheet" type="text/css" href="{{URL::asset('public_css/base.css') }}" />
<link rel="stylesheet" type="text/css" href="{{URL::asset('handan/css/footer.css') }}"/>
<link rel="stylesheet" type="text/css" href="{{URL::asset('recommend/css/recommendcenter.css') }}">
<script type="text/javascript" src="{{ URL::asset('public_js/jquery-1.12.4.min.js') }}"></script>
@include('new.newheader')
<div class="main clearfloat">
    <div class="left">
        <div class="top">
            <div class="head"><img src="{{$userInfo->photo}}" alt=""></div>
            <div class="name">
                <span>{{$userInfo->nickname}}</span>
                <span class="vip">
                    <img src="{{ URL::asset('recommend/images/recommendcenter/v.png') }}" alt="">
                </span>
            </div>
            <div class="brief">
                <div style="width:316px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin: 0 auto;">{{$userInfo->intro}}</div>
            </div>
          
            <div class="addr">
                <span><img src="{{ URL::asset('recommend/images/recommendcenter/addr.png') }}" alt=""></span>
                <span>{{$userInfo->province}} {{ $userInfo->city}} {{ $userInfo->country}}</span>
            </div>
        </div>
        <div class="center">
            <div>
                <p>订阅人数</p>
                <p>{{$userInfo->followCount}}人</p>
            </div>
            <div>
                <p>总篇数</p>
                <p>{{$userInfo->count}}</p>
            </div>
            <div>
                <p>总赞数</p>
                <p>{{$userInfo->allUpvotes}}</p>
            </div>
        </div>
        @if($id != Session::get('eai')['id'])
<!--            <div class="bot">
                <span>＋ 订阅</span>
            </div>-->
        @endif
        
    </div>
    <div class="right">
        <!-- 发布历史详情 -->
    @if($RecommandList)
        @foreach($RecommandList as $val)
        <div class="history">
            <div class="intro clearfloat">
                <div class="photo">
                    <img src="{{ $val['userPhoto'] }}" alt="">
                </div>
                <div class="name">
                    <span>{{ $val['nickname'] }}</span>
                    <span class="vip"><img src="{{ URL::asset('recommend/images/recommendcenter/v.png') }}" alt=""></span>
                    <p class="brief">
                        <span><img src="{{ URL::asset('recommend/images/recommendcenter/crown.png') }}" alt=""></span>
                        <span>数据分析师</span>
                    </p>
                </div>
                @if($id != Session::get('eai')['id'])
                <div class="btn">
                    <img src="{{ URL::asset('recommend/images/recommendcenter/subscribe.png') }}" alt="">
                </div>
                @endif
            </div>
            <div class="detail">
                <div class="desc">
                    {{$val['content']}}
                </div>
                <div class="chart">
                    @foreach($val['photo'] as $v)
                        <span><img src="{{$v}}" alt=""></span>
                    @endforeach
                </div>
                <!-- 本周推荐 -->
                <div class="week clearfloat">
                    <p>本周推荐</p>
                    <ul>
                         @foreach($val['analystInfo'] as $k)
                        <li>
                            <div>
                                <p class="photo">
                                    <img src="{{ $k->photo }}" alt="">
                                    <span><img src="{{ URL::asset('recommend/images/recommendcenter/vip@greatmaster.png') }}" alt=""></span>
                                </p>
                            </div>
                            <div>
                                <p class="name">{{ $k->username }}</p>
                                <p class="zhiwei">行情分析师</p>
                                 @if($id != Session::get('eai')['id'])
                                    <p class="btn">
                                       <span class="icon"><img src="{{ URL::asset('recommend/images/recommendhistory/add.png') }}" alt=""></span>
                                       <span>@if($k->direction == 0) 正向 @else 反向 @endif</span>
                                   </p> 
                                 @else 
                                    <!-- 个人历史发布中不需要加号按钮 -->
                                     <p class="btn" style="background-color: transparent;color: #9ad5ff;cursor: default;">
                                        <span>@if($k->direction == 0) 正向 @else 反向 @endif</span>
                                    </p>
                                @endif
                            </div>
                        </li>
                        @endforeach
                    </ul>
                </div>
                <!-- 发布时间 -->
                <div class="releaseTime clearfloat">
                    <div class="time"><?php echo date('Y-m-d H:i:s',$val['time']); ?></div>
                    <div class="fabulous">
                        <span>订阅人数</span>
                        <span>{{$val['everyFollowCount']}}</span>&nbsp;&nbsp;
                        <span onclick="fabulous(this);">
                            <span class="img">
                                <img src="{{ URL::asset('recommend/images/recommendcenter/fabulous.png') }}" alt="">
                            </span>
                            <span class="num">{{$val['upvotes']}}</span>
                        </span>
                    </div>
                </div>
            </div>
        </div>
        @endforeach
        <!-- 分页 -->
        {{ $RecommandList->links() }} 
    @else
        <div class="warmTips">您还没有发布内容呢</div>
    @endif
    </div>
</div>
<!-- 底部 -->
@include('layout.footer')
<script>
    (function($){
        $.fn.moreText = function(options){
            var defaults = {
                maxLength:50,
                mainCell:".desc",
                openBtn:'展开',
                closeBtn:'收起'
            }
            return this.each(function() {
                var _this = $(this);
                
                var opts = $.extend({},defaults,options);
                var maxLength = opts.maxLength;
                var TextBox = $(opts.mainCell,_this);
                var openBtn = opts.openBtn;
                var closeBtn = opts.closeBtn;
                
                var countText = TextBox.html();
                var newHtml = '';
                if(countText.length > maxLength){
                    newHtml = countText.substring(0,maxLength)+'...<span class="more">'+openBtn+'</span>';
                }else{
                    newHtml = countText;
                }
                TextBox.html(newHtml);
                TextBox.on("click",".more",function(){
                    if($(this).text()==openBtn){
                        TextBox.html(countText+' <span class="more">'+closeBtn+'</span>');
                    }else{
                        TextBox.html(newHtml);
                    }
                })
            })
        }
    })(jQuery);
    $(function(){
        $(".detail").moreText({
            maxLength: 100, //默认最大显示字数，超过...
            mainCell: '.desc' //文字容器
        });
    })
    // 点赞
    function fabulous(obj) {
        var fabulousNum = Number($(obj).children('.num').text());
        fabulousNum++;
        $.ajax({
            url: '',
            type: 'get',
            data: {fabulousNum: fabulousNum},
            success: function(res) {

            }
        })
    }
</script>
